<?php

/**
 * This file is part of the Pagizer package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @copyright   Copyright (c) 2010 Advisa (http://www.advisa.fr)
 * @author      Pagizer Core Team <team@pagizer.org>
 * @package     pagizer
 * @subpackage  iphone
 */

class m_iphone_actions_IphoneDeleteFolderContentAction extends f_core_Action
{
	public function execute()
	{
		$docId = $this->getRequestParameter("docId");
		$lang = $this->getRequestParameter("docLang", $this->getContext()->getDefaultLang());
        $error = false;

		if(!is_null($docId))
		{
            $docProvider = $this->getDocumentProvider();

            if($docProvider->checkDocument($docId, $lang))
            {
                $content = $docProvider->getByUniqueId($docId, $lang);
                $content->deleteRecursive();
            }
            else
            {
                $error = true;
            }
        }
        else
        {
            $error = true;
        }

        $xml = m_iphone_services_IphoneService::getInstance()->genericConfirm($error);
        return $xml;
	}	
	
	public function validate()
	{
		return $this->getUserContext()->hasRight("backoffice_accessBo");
	}
	
	public function errorHandler()
	{
	}
}